<%@ page language="java" contentType="text/html;UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.bear.model.entity.forum.actionForm.*" %>
<%@ page import="com.bear.model.entity.User" %>
<%@include file="../base.jsp" %>

<title>我的资料</title>
<script>

$(function(){

$("input[type='file']").change(function(evt){

        var files = evt.target.files; 
        for (var i = 0, f; f = files[i]; i++) {
         if (!f.type.match('image.*')) {
           continue;
          }
          var reader = new FileReader();
         reader.onload = (function(theFile) {
            return function(e) {                                
            $("#list img").attr("src",e.target.result);  //预览图片的位置                 
           };
         })(f);

        reader.readAsDataURL(f);

        }

    });

});



function open1(){
	$('#wmodify').window('open');
}
function open2(){
	$('#wupload').window('open');
}
function close1(){
	$('#wmodify').window('close');
}
function close2(){
	$('#wupload').window('close');
}
function modify(){
	var a = $('#ff');
	a.submit();
}
function upload(){
	var a = $('#headphoto');
	var filename = $('#fil').val();
	var suffix=filename.substring(filename.lastIndexOf("."),filename.length);
	if (suffix=='.jpg')
	{	
		//alert(suffix);
		a.submit();
	}
	else
	{
		$("#suffixerror").html("<font color='red'>文件格式不对</font>");
	}
	
	
}
</script>

</head>
<body>
<%User u = (User)request.getAttribute("userData");
%>
<img src="<c:url value="/ico/egg.jpg"/>" height="50"><font class="thick">我的资料</font><br>
<div class="demo-info">
	<div class="demo-tip icon-tip"></div>
	<div>快来完善我的资料吧！</div>
</div>
<a href="<c:url value="/App.html"/>" class="easyui-linkbutton" >首页</a>
<a href="<c:url value="/userInfo.html"/>" class="easyui-linkbutton" >看看都有谁</a>
<a href="#" class="easyui-linkbutton" onclick="open1()">修改我的资料</a>
<a href="#" class="easyui-linkbutton" onclick="open2()">上传头像</a>
<a href="#" class="easyui-linkbutton" onclick="logout()">修改密码</a>
<table>
	<tr>
	<td rowspan="3"><img 
<%if(u.getPhotoAddress()==null){ %>	
src="<c:url value="/ico/head.jpg"/>" 
<%}
else{ %> 
src="<c:url value="<%=u.getPhotoAddress() %>"/>" 
<%} %>
height="150"></td>
	<td>用户名：</td><td><%=u.getUsername() %></td>
	</tr>
	<tr>
	<td rowspan="2">个性签名：</td><td><%=u.getSign() %></td>
	</tr>
</table>

<div id="wmodify" class="easyui-window" data-options="title:'资料修改',closed:true" style="width:300px;height:250px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false" style="padding:10px;background:#fff;border:1px solid #ccc;">
			<!-- 表单-->
			<div style="background:#fafafa;padding:10px;width:200px;height:100px;">
	    	<form id="ff" method="post" novalidate action="<c:url value="/userInfo/mydata.html"/>">
	        <div>
	            <label for="sign">个性签名:</label>
	            <textarea name="sign" style="height:60px;" name="sign" ><%=u.getSign() %></textarea>
	        </div>
	        <input type="hidden" name="resign" value="true">
	    	</form>
	    	</div>
	    	</div>
	    	<!-- 表单完-->
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:modify()">修改</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:close1()">取消</a>
			</div>
		</div>
</div>
<div id="wupload" class="easyui-window" data-options="title:'头像上传',closed:true" style="width:300px;height:250px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false" style="padding:10px;background:#fff;border:1px solid #ccc;">	
	   	<form id="headphoto" enctype="multipart/form-data" action="<c:url value="/userInfo/uploading.html"/>" method="post">
	   	150*150的图片效果更佳<br>
	   	只能是后缀为.jpg的图片文件
	   	<div id='suffixerror'></div>
	   	<input type="file" id="fil" name="fil"/>
  		<div id="list"><img src="" height="150"></div>
 		</form>
	    </div>
	    	
		<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0;">
			<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:upload()">上传</a>
			<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:close2()">取消</a>
		</div>
		</div>
</div>
	
<%@include file="../botton.jsp" %>
</body>
</html>